package com.example.et.controller;

import com.example.et.entity.Mechanism;
import com.example.et.entity.Result;
import com.example.et.mapper.MechanismMapper;
import com.example.et.service.MechanismService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mech")
public class MechanismController {

    @Autowired
    private MechanismService mechanismService;

    @Autowired
    private MechanismMapper mapper;

    @GetMapping("/")
    public Result getMach()
    {
        List<Mechanism> mechanisms = mapper.getInformation();
        try {
            return Result.success(mechanisms);
        }catch (Exception e){
            return Result.error(e.getMessage());
        }

    }

    @GetMapping("/chegong")
    public Result getCheGongs()
    {
        List<Mechanism> mechanisms = mapper.getCheGong();
        try {
            return Result.success(mechanisms);
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }


    @GetMapping("/che")
    public Result getChes()
    {
        List<Mechanism> mechanisms = mapper.getChe();
        try {
            return Result.success(mechanisms);
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }



}
